import java.util.List;

public class TestCourseSelection {
    public static void main(String[] args) {
        // 创建教师
        Teacher teacher1 = new Teacher("T001", "张老师", "男");
        Teacher teacher2 = new Teacher("T002", "王老师", "女");

        // 创建课程
        Course course1 = new Course("C001", "Java 编程", "教学楼 101", "周一 8:00-9:40");
        Course course2 = new Course("C002", "数据结构", "教学楼 102", "周一 10:00-11:40");

        // 教师开课
        teacher1.setCourse(course1);
        teacher2.setCourse(course2);
        course1.setTeacher(teacher1);
        course2.setTeacher(teacher2);
        System.out.println(teacher1.getName() + " 开设了 " + course1.getCourseName() + " 课程");
        System.out.println(teacher2.getName() + " 开设了 " + course2.getCourseName() + " 课程");

        // 创建学生
        Student student1 = new Student("S001", "小黄", "男");
        Student student2 = new Student("S002", "小红", "女");

        // 学生选课
        student1.selectCourse(course1);
        student1.selectCourse(course2);
        student2.selectCourse(course1);

        // 学生退课
        student1.dropCourse(course2);

        // 打印学生课表
        System.out.println("\n小黄的课表：");
        printCourseSchedule(student1);

        System.out.println("\n小红的课表：");
        printCourseSchedule(student2);
    }

    public static void printCourseSchedule(Student student) {
        List<Course> courses = student.getSelectedCourses();
        if (courses.isEmpty()) {
            System.out.println(student.getName() + " 暂无选课");
            return;
        }
        System.out.println("编号\t课程名称\t\t上课地点\t\t时间\t\t授课教师");
        for (Course course : courses) {
            System.out.printf("%s\t%s\t%s\t%s\t%s%n",
                    course.getId(),
                    course.getCourseName(),
                    course.getLocation(),
                    course.getTime(),
                    course.getTeacher().getName());
        }
    }
}
